package com.lemon.ashe.service;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Service;

/**
 * @program: SpringBootZoo
 * @author: Mr.Young
 * @create: 2021/4/6 23:24
 **/
@EnableBinding(Sink.class)
@Service
public class AsheService {

    public String hello(Integer id) {
        return "线程池：" + Thread.currentThread().getName() + " id is: " + id;
    }

    public String hello_timeout(Integer id){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "timeout 线程池：" + Thread.currentThread().getName() + " id is: " + id;
    }

    @StreamListener(Sink.INPUT)
    public void input(Message<String> message){
        System.out.println("接受消息："+message.getPayload());
    }
}
